home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_061 / filldisk / filldisk.c < prev   
C/C++ Source or Header  |  1992-05-06  |  1KB  |  52 lines

  1. /*
  2.  *    A simple minded, 5 minute, program to trash all free blocks on a
  3.  *    disk by just writing a file full of garbage until the disk is full.
  4.  *
  5.  *    This insures that any proprietary data left on the disk after
  6.  *    deleting files is clobbered.   Otherwise, disksalv might find
  7.  *    some interesting tidbits...
  8.  *
  9.  *    To use, just run and wait for the requestor to come up when
  10.  *    the disk is full.  Cancel the requestor and the file "junkfile"
  11.  *    will be left, and the disk will be full.  Delete the file
  12.  *    to free up the scribbled blocks.
  13.  *
  14.  */
  15.  
  16. #include <stdio.h>
  17.  
  18. static char buf[512];
  19.  
  20. #define FILENAME "junkfile"
  21. #define MSG "This block has been subjected to bit rot (better luck next time!)"
  22.  
  23. int main ()
  24. {
  25.     register FILE *fp;
  26.     register int count = 0;
  27.  
  28.     if ((fp = fopen (FILENAME, "r")) != NULL) {
  29.         (void) fprintf (stderr, "%s: file exists already!\n", FILENAME);
  30.     } else {
  31.         (void) fclose (fp);
  32.         if ((fp = fopen (FILENAME, "w")) == NULL) {
  33.             (void) fprintf (stderr, "%s: can't open for write!\n",
  34.                 FILENAME);
  35.         } else {
  36.             (void) strcpy (buf, MSG);
  37.             while (fwrite (buf, sizeof (buf), 1, fp) == 1) {
  38.                 count++;
  39.                 if ((count % 100) == 0) {
  40.                     (void) printf ("Reached block %d ...\r",
  41.                          count);
  42.                     (void) fflush (stdout);
  43.                 }
  44.             }
  45.             (void) printf ("Total of %d blocks written\n", count);
  46.             (void) fflush (stdout);
  47.             (void) fclose (fp);
  48.         }            
  49.     }
  50.     return (0);
  51. }
  52.